<?php
defined('_JEXEC') or die('Restricted access');

?>
<script type="text/javascript" src="<?php echo JURI::root(true); ?>/media/system/js/mootools-core.js"></script>
<!--<script type="text/javascript" src="<?php echo JURI::root(true); ?>/media/system/js/mootools-more.js"></script>
<script type="text/javascript" src="<?php echo JURI::root(true); ?>/media/system/js/mootools-more-uncompressed.js"></script>-->
<javascript library="jquery" plugin="jquery"/>

<script type="text/javascript">
    window.addEvent( "domready", function()
    {
        var url = "<?php echo JURI::base();?>index.php";
        $("county1").addEvent("change",function(E){
          document.getElementById("district1").innerHTML ="<img src=\"components/com_taxi_booking/assets/images/ajax-loader.gif\" align=\"center\">";

            new Request({
                url:url, // now the class for ajax call is Request
                method :'get',
                onSuccess: function(responseText) { // no default update element, we do it manually
                    //                    alert(responseText)
                    document.getElementById("district1").innerHTML=responseText;
                }
            }).send('option=com_taxibooking&task=getCountyDistricts&county='+this.value);
              //            new Ajax( "index.php?option=com_taxibooking&task=getCountyDistricts" , opt ).request();
        });
        $("county2").addEvent("change",function(E){

            new Request({
                url:url, // now the class for ajax call is Request
                method :'get',
                onSuccess: function(responseText) { // no default update element, we do it manually
                    //                    alert(responseText)
                    document.getElementById("district2").innerHTML=responseText;
                }
            }).send('option=com_taxibooking&task=getCountyDistricts&county='+this.value);

        });
        
        $("airports1").addEvent("change",function(E){
              document.getElementById("fixed_route").selectedIndex="";
        });
        $("airports2").addEvent("change",function(E){
              document.getElementById("fixed_route").selectedIndex="";
        });
        
        $("fixed_route").addEvent("change",function(E){
            /*$("airport1").setProperty('checked', false);
            $("zip1").setProperty('checked', false);
            $("airport2").setProperty('checked', false);
            $("zip2").setProperty('checked', false);*/
            
            $$('.col1').getElements('input').each(function (el, num){
                    el.set('value', '');
            });
            $$('.col1').getElements('select').each(function (el, num){
                    el.set('value', '');
            });
        });
    });


    function ShowElement(elem)

    {
        document.getElementById("fixed_route").selectedIndex="";
        
        if (elem=='aphide1'){
            document.getElementById("aphide1").style.display = "block";	
            //document.getElementById("sphide1").style.display = "none";	
            document.getElementById("zphide1").style.display = "none";	}

        //if (elem=='sphide1'){document.getElementById("sphide1").style.display = "block";	document.getElementById("aphide1").style.display = "none";	document.getElementById("zphide1").style.display = "none";	}

        if (elem=='zphide1'){
            document.getElementById("zphide1").style.display = "block";	
            //document.getElementById("sphide1").style.display = "none";	
            document.getElementById("aphide1").style.display = "none";	}



        if (elem=='aphide2'){
            document.getElementById("aphide2").style.display = "block";	
            //document.getElementById("sphide2").style.display = "none";	
            document.getElementById("zphide2").style.display = "none";	}

        //if (elem=='sphide2'){document.getElementById("sphide2").style.display = "block";	document.getElementById("aphide2").style.display = "none";	document.getElementById("zphide2").style.display = "none";	}

        if (elem=='zphide2'){
            document.getElementById("zphide2").style.display = "block";	
            //document.getElementById("sphide2").style.display = "none";	
            document.getElementById("aphide2").style.display = "none";	}

    }

    function check_pass(passengers)	{

        var suitc = document.getElementById("suitcases").value;

        var infantseats = document.getElementById("infantseats").value;

        var chseats = document.getElementById("chseats").value;

        var boosterseats = document.getElementById("boosterseats").value;

        

        passengers = parseInt(passengers) + parseInt(infantseats) + parseInt(chseats) + parseInt(boosterseats);

        //alert(passengers);

        //	if(((passengers > 0) || (suitc > 0)) && (passengers <= 4) && (suitc <= 4)) {

        if(((passengers > 0) || (suitc > 0)) && (passengers <= 4) && (suitc <= 3)) {

            document.getElementById("saloon").disabled = false;

            document.getElementById("saloon").checked = true;

            document.getElementById("mpv").disabled = true;

            document.getElementById("8seat").disabled = true;

        } else if((passengers > 5) || (suitc > 5)) {

            document.getElementById("saloon").disabled = true;

            document.getElementById("mpv").disabled = true;

            document.getElementById("8seat").disabled = false;

            document.getElementById("8seat").checked = true;

            //		} else if(((passengers > 4) || (suitc > 4)) && ((passengers <= 5) || (suitc <= 5))) {

            //} else if(((passengers > 3) || (suitc >= 4)) && ((passengers <= 5) || (suitc <= 5))) {

        } else if(((passengers > 4) || (suitc >= 4)) && ((passengers <= 5) || (suitc <= 5))) {

            document.getElementById("saloon").disabled = true;

            document.getElementById("mpv").disabled = false;

            document.getElementById("mpv").checked = true;

            document.getElementById("8seat").disabled = true;

        } else {

            document.getElementById("saloon").disabled = false;

            document.getElementById("mpv").disabled = false;

            document.getElementById("8seat").disabled = false;

            document.getElementById("saloon").checked = false;

            document.getElementById("mpv").checked = false;

            document.getElementById("8seat").checked = false;

        }

    }

    function check_cases(suitcases)	{

        var pass = document.getElementById("passengers").value;

        if(((pass > 0) || (suitcases > 0)) && (pass <= 4) && (suitcases <= 3)) {

            document.getElementById("saloon").disabled = false;

            document.getElementById("saloon").checked = true;

            document.getElementById("mpv").disabled = true;

            document.getElementById("8seat").disabled = true;

        } else if((pass > 5) || (suitcases > 5)) {

            document.getElementById("saloon").disabled = true;

            document.getElementById("mpv").disabled = true;

            document.getElementById("8seat").disabled = false;

            document.getElementById("8seat").checked = true;

        } else if(((pass > 4) || (suitcases >= 4)) && ((pass <= 5) || (suitcases <= 5))) {

            document.getElementById("saloon").disabled = true;

            document.getElementById("mpv").disabled = false;

            document.getElementById("mpv").checked = true;

            document.getElementById("8seat").disabled = true;

        } else {

            document.getElementById("saloon").disabled = false;

            document.getElementById("mpv").disabled = false;

            document.getElementById("8seat").disabled = false;

            document.getElementById("saloon").checked = false;

            document.getElementById("mpv").checked = false;

            document.getElementById("8seat").checked = false;

        }

    }

</script>



<div id="booking" class="booking">



    <div style="width:100%;">

        <?php
// render the toolbar on the page. rendering it here means that it is displayed on every view of your component.
//echo TaxiBookingHelperToolbar::preferences('com_taxibooking', '550', '570', JText::_('CONFIGURATION'));
        $user = & JFactory::getUser();
    
        $groups =$user->get('groups');
        $gid = array_keys($groups);
        if ($gid[0] == 8 || $gid[0]==7)// if the logged in user is admin or super user
        {
            echo '<div style="width:200px;float:right;">';
            echo '<div style="width:80px;float:left;">
                    <a href="' . JRoute::_('index.php?option=com_taxibooking&view=settings') . '">' . JText::_(SETTINGS) . '</a></div>';
            echo '<div style="width:80px;float:left;">
                    <a href="' . JRoute::_('index.php?option=com_taxibooking&view=orders') . '">' . JText::_(ORDERS) . '</a></div>';
            echo '</div>';
        }
        ?>


    </div>

    <form name="book_taxi" action="<?php echo $this->action ?>" method="post">

        <div class="sized_head">

            <div class="componentheading">

                <h2><?php echo JText::_(BOOKING_HEADER); ?></h2>

            </div>

            <div class="contenth">

                <div id="prev1">

                    <div id='prev2' align='center'>

                        <div class="col1"> <!-- FROM And To closing -->
                        <fieldset style="border-color: white; width: '90%'">



                            <legend><?php echo JText::_(TAXI_FROM); ?></legend>

                            <table border=0 width='95%'>

                                <tr>

                                    <td width="30%">



                                        <label for="airport1">

                                            <input type="radio" class="radio" name="from_dest" id="airport1" value="0" <?php echo ($this->from_dest == 0) ? 'checked="checked"' : ''; ?> onClick="ShowElement('aphide1')" />

                                            <?php echo JText::_(INTEREST_POINTS); ?>

                                        </label>

                                        <br />

                                        <label for="zip1">

                                            <input name="from_dest" id="zip1" value="1" <?php echo ($this->from_dest == 1) ? 'checked="checked"' : ''; ?> type="radio" class="radio" onClick="ShowElement('zphide1')" />

                                            <?php echo JText::_(ZIP); ?>

                                        </label>

                                        <br />



                                        <!--label for="seaport1">

                                            <input name="from_dest" id="seaport1" value="2" <?php echo ($this->from_dest == 2) ? 'checked="checked"' : ''; ?> type="radio" class="radio" onClick="ShowElement('sphide1')" />

                                        <?php echo JText::_(SEAPORTS); ?>

                                                </label-->



                                        </td>

                                        <td width="70%">

                                            <span id="aphide1" style="<?php echo ($this->from_dest == 0) ? 'display: block' : 'display: none'; ?>">

                                                <label><?php echo JText::_(SELECT_COLLECTION_PLACE); ?>:</label><br />

                                            <?php echo $this->lists['airports1']; ?>

                                        </span>



                                        <span id='zphide1' style="<?php echo ($this->from_dest == 1) ? 'display: block' : 'display: none'; ?>">

                                            <label><?php echo JText::_(ENTER_COLLECTION_PLACE); ?>:</label><br>

                                            <div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(STREET); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="street1" value="<?php echo ($this->from_dest == 1) ? $this->street1 : ''; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(TOWN); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="town1" value="<?php echo ($this->from_dest == 1) ? $this->town1 : $this->elsettings->default_city; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(COUNTY); ?></label></div>

                                                    <div class="postcode_div_input"><?php echo $this->lists['county1']; ?></div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(DISTRICT); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <?php echo $this->lists['districts1']; ?>
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(POSTCODE); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="postcode1" value="<?php echo ($this->from_dest == 1) ? $this->postcode1 : ''; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(COUNTRY); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="country1" value="<?php echo ($this->from_dest == 1) ? $this->country1 : $this->elsettings->default_country; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                            </div>

                                        </span>



            <!--span id='sphide1' style="<?php echo ($this->from_dest == 2) ? 'display: block' : 'display: none'; ?>">

                <label><?php echo JText::_(SELECT_COLLECTION_PLACE); ?>:</label><br>

                                        <?php echo $this->lists['seaports1']; ?>

                                            </span-->

                                                    </td>

                                                </tr>

                                                <tr><th colspan="2" style="color: #ff0000; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif;">

                                                        <i><?php if ($this->from_error != "")
                                                            echo $this->from_error . "<br>"; ?></i>

                                                </th>

                                            </tr>

                                        </table>

                                    </fieldset>

                                    <p></p>

                                    <fieldset style="border-color: white; width: '90%'">

                                        <legend><?php echo JText::_(TAXI_TO); ?></legend>

                                        <table border=0 width='95%'>

                                            <tr>

                                                <td width='30%'>

                                                    <label for="airport2">

                                                        <input name="to_dest" id="airport2" value="0" <?php echo ($this->to_dest == 0) ? 'checked="checked"' : ''; ?> type="radio" class="radio" onClick="ShowElement('aphide2')" />

                                            <?php echo JText::_(INTEREST_POINTS); ?>

                                                    </label>

                                                    <br>

                                                    <label for="zip2">

                                                        <input name="to_dest" id="zip2" value="1" <?php echo ($this->to_dest == 1) ? 'checked="checked"' : ''; ?> type="radio" class="radio" onClick="ShowElement('zphide2')" />

                                            <?php echo JText::_(ZIP); ?>

                                                    </label><br>

                                                    <!--label for="seaport2">

                                                        <input name="to_dest" id="seaport2" value="2"<?php echo ($this->to_dest == 2) ? 'checked="checked"' : ''; ?> type="radio" class="radio" onClick="ShowElement('sphide2')" />

                                        <?php echo JText::_(SEAPORTS); ?>

                                                                </label-->

                                                    </td>

                                                    <td width="70%">

                                                        <span id='aphide2' style="<?php echo ($this->to_dest == 0) ? 'display: block' : 'display: none'; ?>">

                                                            <label><?php echo JText::_(SELECT_DESTINATION_PLACE); ?>:</label><br>

                                            <?php echo $this->lists['airports2']; ?>

                                                    </span>



                                                    <span id='zphide2' style="<?php echo ($this->to_dest == 1) ? 'display: block' : 'display: none'; ?>">

                                                        <label><?php echo JText::_(ENTER_DESTINATION_PLACE); ?>:</label><br>

                                              <!--input type="text" id='zipcode2' name='zipcode2' size='1' maxlength='20' style='font-size:12px; width:250px;' value="<?php echo ($this->to_dest == 1) ? $this->zipcode2 : ''; ?>" /-->

                                                <div>

                                                    <div class="postcode_div">

                                                        <div class="postcode_div_label"><label><?php echo JText::_(STREET); ?></label></div>

                                                        <div class="postcode_div_input">
                                                            <input type="text" name="street2" value="<?php echo ($this->to_dest == 1) ? $this->street2 : ''; ?>" style="width:130px;" />
                                                        </div>

                                                    </div>

                                                    <div class="postcode_div">

                                                        <div class="postcode_div_label"><label><?php echo JText::_(TOWN); ?></label></div>

                                                        <div class="postcode_div_input">
                                                            <input type="text" name="town2" value="<?php echo ($this->to_dest == 1) ? $this->town2 : $this->elsettings->default_city; ?>" style="width:130px;" />
                                                        </div>

                                                    </div>

                                                    <div class="postcode_div">

                                                        <div class="postcode_div_label"><label><?php echo JText::_(COUNTY); ?></label></div>

                                                        <div class="postcode_div_input"><?php echo $this->lists['county2']; ?></div>

                                                    </div>

                                                    <div class="postcode_div">

                                                        <div class="postcode_div_label"><label><?php echo JText::_(DISTRICT); ?></label></div>

                                                        <div class="postcode_div_input">
                                                        <?php echo $this->lists['districts2']; ?>
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(POSTCODE); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="postcode2" value="<?php echo ($this->to_dest == 1) ? $this->postcode2 : ''; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                                <div class="postcode_div">

                                                    <div class="postcode_div_label"><label><?php echo JText::_(COUNTRY); ?></label></div>

                                                    <div class="postcode_div_input">
                                                        <input type="text" name="country2" value="<?php echo ($this->to_dest == 1) ? $this->country2 : $this->elsettings->default_country; ?>" style="width:130px;" />
                                                    </div>

                                                </div>

                                            </div>

                                        </span>



                    <!--span id='sphide2' style="<?php echo ($this->to_dest == 2) ? 'display: block' : 'display: none'; ?>">

                        <label><?php echo JText::_(SELECT_DESTINATION_PLACE); ?>:</label><br>

                                        <?php echo $this->lists['seaports2']; ?>

                                                                    </span-->

                                                    </td>

                                                </tr>

                                                <tr><th colspan="2" style="color: #ff0000; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif;">

                                                        <i><?php if ($this->to_error != "")
                                                            echo $this->to_error . "<br>"; ?></i>

                                                    <i><?php if ($this->zip_error != "")
                                                            echo "<br>" . $this->zip_error . "<br>"; ?></i></th>

                                            </tr>

                                        </table>

                                    </fieldset>
                                    
                    </div> <!-- FROM And To closing -->
                    
                    <div class="col2">
                        <div id="fixed_route_or"><h2><?php echo JText::_('SPECIAL_OFFERS'); ?></h2></div>
                        <div id="fixed_route_lbl"><?php echo JText::_('FIXED_ROUTE_MESSAGE'); ?></div>
                        <div id="fixed_route_list">
                            <?php echo $this->lists['fixed_routes']; ?>
                        </div>
                    </div>
                    
                                    
                 <div class="passengers">
                <fieldset style="border-color: white; width: '90%';">

                    <legend><?php echo JText::_(RETURN_SEATS); ?></legend>

                    <div id='txt'>



                        <table border="0" width="100%">



                            <tr><td>

                                    <table width="100%" cellspacing="0" cellpadding="0" border="0">

                                        <tr width="100%">

                                            <td width="50%" align="left">

                                                <div style="width:252px;float: left;">

                                                    <div style="width:150px;float: left;"><label><?php echo JText::_(PASSENGER_SEATS); ?>:</label></div>

                                                    <div style="width:100px;float: left;"><?php echo $this->lists['passengers']; ?></div>

                                                </div>

                                                <div style="width:252px;float: left;">

                                                    <div style="width:150px;float: left;"><label><?php echo JText::_(SUITCASE_NO); ?>:</label></div>

                                                    <div style="width:100px;float: left;"><?php echo $this->lists['suitcases']; ?></div>

                                                </div>

                                                <div style="width:252px;float: left;">

                                                    <div style="width:150px;float: left;"><label><?php echo JText::_(BOOSTER_SEATS); ?>:</label></div>

                                                    <div style="width:100px;float: left;"><?php echo $this->lists['boosterseats']; ?></div>

                                                </div>

                                                <div style="width:252px;float: left;">

                                                    <div style="width:150px;float: left;"><label><?php echo JText::_(INFANT_SEATS); ?>:</label></div>

                                                    <div style="width:100px;float: left;"><?php echo $this->lists['infantseats']; ?></div>

                                                </div>

                                                <div style="width:252px;float: left;">

                                                    <div style="width:150px;float: left;"><label><?php echo JText::_(CHILD_SEATS); ?>:</label></div>

                                                    <div style="width:100px;float: left;"><?php echo $this->lists['chseats']; ?></div>

                                                </div>





                                            </td>



                                            <td width="50%" align="left">

                                                <p align="left">

                                                    <label for='returnjurney'>

                                            <?php echo JText::_(BOOK_RETURN); ?>

                                            <input name='returnjurney' class='radio' value='returnjurney' type='checkbox' id='returnjurney' <?php echo ($this->returnjurney == 1) ? " checked" : ""; ?> />

                                        </label>

                                    </p>

                                    <p align="left">

                                        <font size='1pt'><?php
                                        echo JText::_(BOOK_RETURN_DISCOUNT_MESSAGE1).$this->elsettings->discount. JText::_(BOOK_RETURN_DISCOUNT_MESSAGE2); ?></font>

                                    </p>

                                </td>

                            </tr>

                        </table>



                    </td></tr>

                <div style="color: #ff0000; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif;">

                    <center><i><?php if ($this->passenger_error != "")
                                                echo $this->passenger_error . "<br>"; ?></i></center>

                                </div>



                            </table>	</div>

                    </fieldset><p></p>

					</div><!-- End of div class="passengers" -->

                    <fieldset style="border-color: white; width: '90%';">

                        <legend><?php echo JText::_(VEHICLE_TYPE); ?></legend>

                        <table width="100%" border=0 cellpadding=5>

                            <tr>

                                <td align='center'>

                                    <label for="saloon">

                                        <img src="components/com_taxibooking/assets/images/saloon.png" alt="Saloon"  border="1" /><br><br>

                                        <input name="vehicle" id="saloon" value="0" type="radio" class="radio"<?php echo ($this->vehicle == 0) ? ' checked="checked"' : ''; ?> />

                        <?php echo JText::_(SALOON); ?>

                                        </label>

                                    </td>

                                    <td align='center'>

                                        <label for="mpv">

                                            <img src="components/com_taxibooking/assets/images/mpv.png" alt="MPV"  border="1" /><br><br>

                                            <input name="vehicle" id="mpv" value="1" type="radio" class="radio"<?php echo ($this->vehicle == 1) ? ' checked="checked"' : ''; ?> />

                        <?php echo JText::_(MPV); ?>

                                        </label>

                                    </td>

                                    <td align='center'>

                                        <label for="8seat">

                                            <img src="components/com_taxibooking/assets/images/8seat.png" alt="8seat"  border="1" /><br><br>

                                            <input name="vehicle" id="8seat" value="2" type="radio" class="radio"<?php echo ($this->vehicle == 2) ? ' checked="checked"' : ''; ?> />

                        <?php echo JText::_(EIGHT_SEATER); ?>

                                        </label>

                                    </td>

                                </tr>

                            </table>

                        </fieldset>

						<div class="bookingmessage">
                        <fieldset style="border-color: white; width: '90%';">

                            <legend><?php echo JText::_(CANT_FIND_YOUR_ADDRESS); ?></legend>

                            <div id='txt'><?php echo JText::_(SPECIAL_DIVERSION_REQUIREMENT) ?><br><br></div>

                        </fieldset>
						</div>


                    </div>

                    <input type="hidden" name="referer" value="<?php echo @$_SERVER[HTTP_REFERER]; ?>" />

                    <?php echo JHTML::_('form.token'); ?>

                    <input type="hidden" name="option" value="com_taxibooking" />

                    <input type="hidden" name="task" value="getPrice" />

                    <input name="Submit" value="Get price" type="submit" class='buttons' title="Next step" />



                </div>

                <b class="b4bh"></b>	<b class="b3bh"></b>	<b class="b2bh"></b>	<b class="b1h"></b>

            </div>

    </form>

    <!-- End booking form -->



</div>